package cn.mldn.microboot.config;

import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.web.servlet.ErrorPage;
import org.springframework.http.HttpStatus;

/**
 * description:
 * Created by gy on 2017/8/13.
 */
//@Configuration
public class ErrorPageConfig {

//    @Bean
    public EmbeddedServletContainerCustomizer embeddedServletContainerCustomizer(){
        return new EmbeddedServletContainerCustomizer() {
            @Override
            public void customize(ConfigurableEmbeddedServletContainer configurableEmbeddedServletContainer) {
                ErrorPage error400 = new ErrorPage(HttpStatus.BAD_REQUEST,"/400.html");
                ErrorPage error404 = new ErrorPage(HttpStatus.NOT_FOUND,"/404.html");
                ErrorPage error500 = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR,"/500.html");
                configurableEmbeddedServletContainer.addErrorPages(error400,error404,error500);
            }
        };
    }
}
